<?php

function v($data)
{
	print_r($data);
	exit;
}

function flash($key = null, $default = null)
{
    return app('request')->session()->flash($key, $default);
}

function makeOrderNumber()
{
	return date('Ymd') . str_pad(mt_rand(1, 9999999), 7, '0', STR_PAD_LEFT);
}

function writeArrayToPhp($array, $file)
{
	
}

// 缩略图相对路径
function thumb($path, $size, $extension='jpg')
{
	if (is_numeric($size)) {
		$width = $height = $size;
	} else {
		list($width, $height) = explode('x', $size);
	}

	if (!$extension) {
		$extension = pathinfo($path, PATHINFO_EXTENSION);
	}

	return $path . "_{$width}x{$height}.{$extension}";
}

// 缩略图全路径
function thumbFull($path, $size, $extension='jpg')
{
	return url(thumb($path, $size, $extension));
}

// 函数将多维数组扁平化成一维且保持Key
function array_flatten_keep(array $array)
{
	$temp = array();
	
    foreach ($array as $value) {
        $temp += $value;
    }

    return $temp;
}